
import React,{Component} from "react";
import { Steps, Form, Input, Radio, Button, DatePicker, message  } from 'antd';
import { Link } from "react-router-dom";
import ajax from '../ajaxMethod';

const Step = Steps.Step;

class Registerthird  extends Component{
    constructor(props){
        super(props);
        this.state = {
            state: 0//0表示正常,1表示链接已经失效
        }   
    }
    componentDidMount(){
        scrollTo(0,0);
        this.init();
    }
    init = () =>{
        let _this = this,
            username = this.props.location.search.replace(/^\?username=/, "");
        //将在临时表里面的用户转移到正式的表，如果不能转移就是这个链接失效了。
        ajax.postAjax("/interface/rigisterSecond",{ username: username},res=>{
            if(res.success){
                if(res.data.state === 1){
                    _this.setState({state: 1});
                }else{
                    //注册成功跳转到登录？？？
                }
            }else{
                console.error(res.description);
                message.error(res.description);
            }
        }, err=>{
            console.error(err);
        })
    }

    render(){
        console.log("proprs", this.props);
        return(
        <div id="register">
            <div className="top">
                <div>
                    <Link to="/"><i className="logo"></i></Link>
                </div>
            </div>
            <div className="content-box">
                <div className="steps">
                    <Steps current={2}>
                        <Step title="信息填写" />
                        <Step title="验证" />
                        <Step title="完成" />
                    </Steps>
                </div>
                {
                    this.state.state === 0?
                    <div className="over">
                        <img src={require("../assets/images/icon_ok.png")} className="ok"></img>
                            <p>恭喜完成注册，赶紧去<Link to="/login"><span>登录</span></Link>吧！</p>
                        <img src={require("../assets/images/approve.png")} className="approve"></img>
                    </div>:
                    <div className="over">
                        <p className="timeout">链接已失效，请重新<Link to="/register"><span>注册</span></Link></p> 
                    </div>
                }
            </div>
        </div>)
    }
}

export default Form.create({})(Registerthird);